package com.atguigu.spzx.model.vo.common;

import com.atguigu.spzx.model.vo.system.ResultCodeEnum;
import lombok.Data;

@Data
public class Result<T>{

    private Integer code;
    private String message;
    private T data;

    public static<T> Result<T> build(Integer code,String message,T data){
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static<T> Result<T> ok(T data){
        Result<T> result = new Result<>();
        result.setCode(ResultCodeEnum.LOGIN_SUCCESS.getCode());
        result.setMessage(ResultCodeEnum.LOGIN_SUCCESS.getMessage());
        result.setData(data);
        return result;
    }

    public static<T> Result<T> ok(){
        Result<T> result = new Result<>();
        result.setCode(ResultCodeEnum.RESPONSE_SUCCESS.getCode());
        result.setMessage(ResultCodeEnum.RESPONSE_SUCCESS.getMessage());
        return result;
    }

    public static<T> Result<T> fail(){
        Result<T> result = new Result<>();
        result.setCode(ResultCodeEnum.LOGIN_ERROR.getCode());
        result.setMessage(ResultCodeEnum.LOGIN_ERROR.getMessage());
        return result;
    }

    public static<T> Result<T> fail(String message){
        Result<T> result = new Result<>();
        result.setCode(ResultCodeEnum.LOGIN_ERROR.getCode());
        result.setMessage(message);
        return result;
    }



}
